package com.sleep.ruledemo.api;

import cn.hutool.extra.spring.SpringUtil;
import com.sleep.ruledemo.domian.R;
import com.sleep.ruledemo.domian.listener.WxListenerMessage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author GuoAo
 * @className EventListenerController
 * @date 2025/6/19
 * @description TODO
 */
@RestController
@RequestMapping("/event")
@RequiredArgsConstructor
public class EventListenerController {

    @PostMapping("/test")
    public R test(@RequestBody List<WxListenerMessage> wxListenerMessages) {
        wxListenerMessages.forEach(wxListenerMessage -> SpringUtil.getApplicationContext().publishEvent(wxListenerMessage));
        return R.ok("success");
    }
}
